﻿using System;
using System.Diagnostics;
using System.Web;

namespace Wheels
{
    public class Client
    {
        private readonly HttpBrowserCapabilitiesBase browser;
        private int height;
        private int width;

        public Client(HttpRequestBase request)
        {
            if (ReferenceEquals(request, null))
                throw new ArgumentNullException("request");

            browser = request.Browser;
        }

        public Client()
        {
            Lat = (decimal) 38.8667590000;
            Lon = (decimal) -77.0541610000;
            ZoomLevel = 10;
        }

        public int ScreenWidth
        {
            [DebuggerStepThrough]
            set { width = value; }
            get
            {
                if (width != 0)
                    return width;

                return Convert.ToInt32(browser["ScreenPixelsWidth"]);
            }
        }

        public int ScreenHeight
        {
            [DebuggerStepThrough]
            set { height = value; }
            get
            {
                if (height != 0)
                    return height;

                return Convert.ToInt32(browser["ScreenPixelsHeight"]);
            }
        }

        public int MapHeight
        {
            get { return 272; }
        }

        public int MapWidth
        {
            get { return 480; }
        }

        public string ImageUrl { get; set; }

        public decimal Lat { get; set; }
        public decimal Lon { get; set; }
        public int ZoomLevel { get; set; }
    }
}